package spring.mvc.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;

/**
 * description:
 * 02配置类
 * 将Controller(Handler)、HandlerMapping、HandlerAdapter 注册到IOC容器。
 *
 * 1. @Configuration 配置类注册到IOC容器
 * 2. @ComponentScan("") 类路径扫描，将Controller类注册到IOC容器
 * 3. @Bean 方法返回的对象注册到IOC容器，完成 HandlerMapping、HandlerAdapter 注册
 */

@Configuration
@ComponentScan("spring.mvc.controller")
public class MvcConfig {

    @Bean
    public RequestMappingHandlerMapping handlerMapping(){
        return new RequestMappingHandlerMapping();
    }

    @Bean
    public RequestMappingHandlerAdapter handlerAdapter(){
        return new RequestMappingHandlerAdapter();
    }

}
